package main

import (
	"gitee.com/baizhige/gin-common-handler/handler"
	"gitee.com/baizhige/gin-common-handler/params"
	"gitee.com/baizhige/go-server-tempalte/app_params"
	"gitee.com/baizhige/go-server-tempalte/common/crud"
	"gitee.com/baizhige/go-server-tempalte/common/router"
	"gitee.com/baizhige/go-server-tempalte/domain/plat_user"
	"gitee.com/baizhige/go-server-tempalte/domain/role"
	"github.com/gin-gonic/gin"
)

func Router(r gin.IRouter) {
	platRouter := r.Group("/plat", router.CommonMiddleware[plat_user.PlatUser])
	//角色增删改查
	crud.Default[role.Role](platRouter)
	//权限增删改查
	crud.Default[role.Permission](platRouter)
	//路由删改查
	crud.Use[router.Router](platRouter, crud.OptPage)
	handler.PUT("/modify", router.Modify, TraceID(), params.Body[router.Router]())
	handler.DELETE("/delete", router.Delete, TraceID(), Path("id", STRING))
	//用户
	crud.Default[plat_user.PlatUser](platRouter)

}

// 简化调用
var (
	Path    = params.Path
	Query   = params.Query
	Header  = params.Header
	TraceID = app_params.TraceId

	INT    = params.INT
	FLOAT  = params.FLOAT
	STRING = params.STRING
	BOOL   = params.BOOL
)
